﻿using ASmile.Com.Da;
using ASmile.ORM.Entitys;
using Microsoft.AspNetCore.Mvc;

namespace ASmile.Web
{
    public class BaseApiCrudController<TBLL, TSaveModel> : BaseApiCrudController<TBLL, TSaveModel, ArgPageData>        
        where TSaveModel : EntityBase, new()
        where TBLL : BLLCrudBase<TSaveModel>, new()
    { }

    public class BaseApiCrudController<TBLL, TSaveModel, TGetListArg> : BaseApiCrudController<TBLL, TSaveModel, TSaveModel, TGetListArg>
        where TGetListArg : ArgPageData, new()
        where TSaveModel : EntityBase, new()
        where TBLL : BLLCrudBase<TGetListArg,TSaveModel, TSaveModel>, new()
    { }

    public class BaseApiCrudController<TBLL, TSaveModel, TListModel, TListArg> : BaseApiController<TBLL>
        where TListArg : ArgPageData, new()
        where TSaveModel : EntityBase, new()
        where TListModel : EntityBase, new()
        where TBLL : BLLCrudBase<TListArg, TSaveModel, TListModel>, new()
    {
        /// <summary>
        /// 获取列表
        /// </summary>
        [HttpPost]
        public virtual ApiResultList<TListModel> GetList(TListArg arg)
        {
            return BLLObj.GetList(arg);
        }
        /// <summary>
        /// 新增
        /// </summary>
        [HttpPost]
        public virtual ApiResult Add(TSaveModel arg)
        {
            return BLLObj.Add(arg);
        }
        /// <summary>
        /// 更新
        /// </summary>
        [HttpPost]
        public virtual ApiResult Update(TSaveModel arg)
        {
            return BLLObj.Update(arg);
        }
        /// <summary>
        /// 删除
        /// </summary>
        [HttpPost]
        public virtual ApiResult Del(TSaveModel arg)
        {
            return BLLObj.Del(arg);
        }
        ///// <summary>
        ///// 删除
        ///// </summary>
        //[HttpPost]
        //public virtual ApiResult DelModel(TSaveModel arg)
        //{
        //    return BLLObj.Del(arg);
        //}
    }
}